<?php

class Default_Model_Area extends Zend_Db_Table_Abstract
{
    protected $_name = 'area';
    public function getAllData(){
    	$query = $this->select()
                        ->from($this->_name)
                        ->where('display = 1')
                        ->order('ord asc');
    	return $this->fetchAll($query);
    }
    public function getDataById($id){
        $query = $this->select()                        
                        ->from($this->_name)
                        ->where('id = ?',(int)$id);
        return $this->fetchRow($query);
    }            
    public function getDataByName($name){
        $query = $this->select()                        
                        ->from($this->_name)
                        ->where('name = ?',$name);
        return $this->fetchRow($query);
    }
    public function addData($data){        
        $data = array('name'    => $data['name'],
                    'ord'       => $data['ord'],                
                    'display'   => $data['display']);                                
        $idAdd = $this->insert($data);        
        return $idAdd;
    }
    public function updateData($id = '',$data){        
        $data = array('name'    => $data['name'],
                    'ord'       => $data['ord'],                
                    'display'   => $data['display']);                            
        return $this->update($data, 'id = '.(int)$id);
    }            
    public function deleteData($id){        
        $this->delete('id = '.(int)$id);
    }
}

